package com.grf.function.controller;

import com.grf.function.service.SimpleService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 简单使用
 * @author: guorf
 * @date: 2024/8/19 23:29
 * @version: v1.0
 */
@Slf4j
@RestController
@RequestMapping("/simple")
@RequiredArgsConstructor
public class SimpleController {

    private final SimpleService simpleService;

    /**
     * @description: 无参无返回值
     * @author: grf
     * @date: 2024/8/20
     */
    @GetMapping("/test1")
    public void test1(){
        simpleService.execute(() -> log.info("no result and no param test1"));
    }
    /**
     * @description: 有参无返回值
     * @author: grf
     * @date: 2024/8/20
     */
    @GetMapping("/test2")
    public void test2(){
        simpleService.execute2(param -> log.info("param and no result test2; param is : {}", param));
    }
    /**
     * @description: 无参有返回值
     * @author: grf
     * @date: 2024/8/20
     */
    @GetMapping("/test3")
    public void test3(){
         var ll = simpleService.execute3(() -> "no param and result test3 :");
         log.info("{}", ll);
    }

    /**
     * @description: 有参有返回值
     * @author: grf
     * @date: 2024/8/20
     */
    @GetMapping("/test4")
    public void test4(){
        var ll = simpleService.execute4(param -> param);
        log.info("param and result test4; param is : {}", ll);
    }
}
